package com.hardy.leetcode;

import java.util.HashSet;

/**
 * User: Ruijie Date: 2016/8/2
 */
public class DiamondCompare {
    public static int compare2(int g1,int g2,int[][] record,int n){
        return 0;
    }
    public static int compare1(int g1, int g2, int[][] record, int n) {
        HashSet<Integer> max = new HashSet<Integer>();
        HashSet<Integer> min = new HashSet<Integer>();
        for (int i = 0; i < record.length; i++) {
            if (record[i][0] == g1) {
                min.add(record[i][1]);
            }
            if (record[i][1] == g1) {
                max.add(record[i][0]);
            }
        }
        for(int i=0;i<n;i++){
            if(max.contains(record[i][1])){
                max.add(record[i][0]);
            }
            if(min.contains(record[i][0])){
                min.add(record[i][1]);
            }
        }
        if(max.contains(g2)&&!min.contains(g2)){
            return 1;
        }else if(min.contains(g2)&&!max.contains(g2)){
            return -1;
        }
        return 0;
    }
}
